﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SoftHotel.Models;

namespace SoftHotel.Controllers
{
    public class DocCompraController : Controller
    {
        //
        // GET: /DocCompra/
        static DocCompraDAO listadoc = new DocCompraDAO();
        private static bool vieneDeEditar = false;
        private static bool vieneDeEliminar = false;
        private static string nombreOriginal = "";
        static DocCompraModel doccompra;
        static List<DocCompraModel> busquedax;
        static DocCompraDAO listadocbusqueda = new DocCompraDAO();
        public DocCompraController()
        {
        }

        public ActionResult Index()
        {

            return View();
        }
        [HttpPost]
        public ActionResult Index(DocCompraModel doc, string button)
        {
            if (button == "Buscar")
            {
                doccompra = doc;
                busquedax = listadoc.buscar(doc);
            }
            listadocbusqueda.dbuscadis = busquedax;
            return RedirectToAction(button);
        }
        public ActionResult Agregar()
        {
            if (!vieneDeEditar && !vieneDeEliminar)
            {

            }
            else
            {
                vieneDeEditar = false;
            }

            return View();
        }
        [HttpPost]
        public ActionResult Agregar(ProductoModel prod, string button, string[] checkbox)
        {
            string mensaje = "";

            return View();
        }
        [HttpPost]
        public ActionResult AgregarGuardarCancelar(string button)
        {
            string method = "Index";
            if (button == "Guardar")
            {

            }
            return RedirectToAction(method); ;
        }
        public ActionResult Agregar2()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Agregar2(string button)
        {
            return View();
        }
        public ActionResult Buscar()
        {

            return View(listadocbusqueda);
        }
        [HttpPost]
        public ActionResult Buscar(string button)
        {

            if (button == "Nueva Busqueda")
            {
                return RedirectToAction("Buscar2", "Producto");

            }
            if (button == "Regresar")
            {
                return RedirectToAction("Index", "Producto");

            }
            return RedirectToAction(button, "Producto");
        }
        public ActionResult Buscar2()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Buscar2(ProductoModel prod, string button)
        {
            if (button == "Buscar")
            {


            }

            return RedirectToAction(button, "Producto");
        }
        public ActionResult Editar(string descripcion)
        {
            nombreOriginal = descripcion;

            return View();
        }
        [HttpPost]
        public ActionResult Editar(ProductoModel prod)
        {
            if (ModelState.IsValid)
            {

                return RedirectToAction("Agregar");
            }

            return View(prod);
        }
        public ActionResult Editar2(string descripcion)
        {
            nombreOriginal = descripcion;

            return View();
        }
        [HttpPost]
        public ActionResult Editar2(ProductoModel prod)
        {
            if (ModelState.IsValid)
            {

                return RedirectToAction("Buscar", "Producto");
            }

            return View(prod);
        }
        public ActionResult Mostrar(string descripcion)
        {
            nombreOriginal = descripcion;

            return View();
        }
        [HttpPost]
        public ActionResult Mostrar(ProductoModel prod, string button)
        {
            return RedirectToAction("Buscar", "Producto");
        }
        public ActionResult Eliminar(string descripcion)
        {
            nombreOriginal = descripcion;


            return View();
        }
        [HttpPost]
        public ActionResult Eliminar(ProductoModel prod, string button)
        {
            if (button == "Aceptar")
            {

            }

            return RedirectToAction("Buscar", "Producto");
        }
        public ActionResult Eliminar2(string descripcion)
        {
            nombreOriginal = descripcion;

            return View();
        }
        [HttpPost]
        public ActionResult Eliminar2(ProductoModel prod, string button)
        {
            if (button == "Aceptar")
            {


                vieneDeEliminar = true;
            }

            return RedirectToAction("Agregar");
        }
        //public ActionResult Mostrar()
        //{
        //    return RedirectToAction("Index");
        //}        
    }
}
